using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	public class RadioInstantiationHelper : InstantiationHelper
	{
		public const int optionHasLabel = 0;

		public const int optionHasIcon = 1;

		[SerializeField]
		private MaterialRadioGroup m_Group;

		[SerializeField]
		private ToggleBase m_ToggleBase;

		[SerializeField]
		private Text m_Label;

		[SerializeField]
		private VectorImage m_Icon;

		public override void HelpInstantiate(int[] options)
		{
			if (options.Contains(0))
			{
				UnityEngine.Object.DestroyImmediate(m_Icon.gameObject);
				m_ToggleBase.graphic = m_Label;
				m_ToggleBase.graphicOffColor = MaterialColor.textDark;
			}
			else if (options.Contains(1))
			{
				UnityEngine.Object.DestroyImmediate(m_Label.gameObject);
				m_ToggleBase.graphic = m_Icon;
				m_ToggleBase.graphicOffColor = MaterialColor.iconDark;
			}
			for (int i = 0; i < 2; i++)
			{
				RectTransform rectTransform = (RectTransform)Object.Instantiate(m_ToggleBase.gameObject).transform;
				rectTransform.SetParent(m_ToggleBase.transform.parent);
				rectTransform.localScale = Vector3.one;
				rectTransform.localEulerAngles = Vector3.zero;
				rectTransform.name = "RadioButton " + (i + 2);
				rectTransform.GetComponent<Toggle>().isOn = false;
			}
			base.HelpInstantiate(options);
		}
	}
}
